﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Transactions {
    import flash.events.*;
    import Events.*;
    import Display.*;

    public class TInitNeighbors extends TFarmTransaction {

        override public function perform():void{
            signedCall("UserService.initNeighbors");
        }
        override public function isInitTransaction():Boolean{
            return (true);
        }
        override protected function onComplete(_arg1:Object):void{
            var _local2:Array = _arg1.neighbors;
            Global.player.maxNeighbors = int(_arg1.neighborMax);
            this.parseNeighbors(_local2);
            dispatchEvent(new Event(Event.COMPLETE));
            Global.world.dispatchEvent(new FarmGameWorldEvent(FarmGameWorldEvent.USER_CHANGED));
        }
        protected function parseNeighbors(_arg1:Array):void{
            var _local2 = !((Global.friendbar == null));
            UI.populateFriendBarData(_arg1);
            if (Global.ui){
                if (_local2){
                    Global.ui.m_friendBar.addPlayerToFriends(Global.friendbar);
                    Global.ui.m_friendBar.updateNeighbors(Global.friendbar);
                } else {
                    Global.ui.m_friendBar.populateNeighbors(Global.friendbar);
                };
                Global.ui.setFriendBarPos(Math.max((Global.friendbar.length - 15), 0));
            };
            dispatchEvent(new Event(Event.COMPLETE));
        }

    }
}//package Transactions 
